package object;

public class ObjectDemo {
    public static void main(String[] args) {
        //toString()方法的演示
        /*Point p=new Point(100,200);
        System.out.println(p);
        System.out.println(p.getX());
        //+p  也是调用了toString方法
        String str="这是一个点："+p;
        System.out.println(str);*/

        /*Point p1=new Point(100,200);
        Point p2=p1;
        Point p3=new Point(100,200);
        System.out.println(p1==p3);
        //equals()方法被重写，重写之后看对象
        System.out.println(p1.equals(p3));*/

        //equals()方法被重写，重写之后看对象
        String s1=new String("abc");
        String s2=new String("abc");
        //String重写了equals方法
        System.out.println(s1.equals(s2));//true
        StringBuilder stringBuilder=new StringBuilder("hello");
        StringBuilder stringBuilder1=new StringBuilder("hello");
        //StringBuilder没有重写equals方法
        System.out.println(stringBuilder.equals(stringBuilder1));//false
        //在比较的过程中，如果引用的类型不同，则直接返回false
        System.out.println(s1.equals(stringBuilder1));
        /*
        * int Integer
        * char Character
        *
        * */
    }
}
